package com.tk.demo.controller;

import com.tk.demo.model.People;
import com.tk.demo.model.Teacher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用来测试springboot的属性文件
 */
@RestController
@EnableConfigurationProperties({People.class, Teacher.class})
public class HelloController {
    @Autowired
    private People people;
    @Autowired
    private Teacher teacher;
    @Value("${user.dir}")
    private String dir;
    @Value("${user.name}")
    private String name;

    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public String HelloWorld() {

        return "Hello, 目录: " + dir + ", 系统名: " + name + ", 属性名: " + people.getName();
    }

    @RequestMapping(value = "/teacher", method = RequestMethod.GET)
    public String HelloTeacher(){
        return "Hello, " + teacher.getName() + ", age: " + teacher.getAge();
    }
}
